{include file="public/header" /}
{load href="__PLUGINS__bootstrap/bootstrap-table.min.css"}
{load href="__PLUGINS__bootstrap/bootstrap-table.min.js"}
<style>
    #des, #des input {
        width: 40px;
        text-align: center;
    }

    #id {
        width: 78px;
    }

    .bs-checkbox {
        width: 36px;
        height: 40px
    }

    .fixed-table-toolbar .columns, .fixed-table-toolbar .search {
        margin-left: 0px;
        margin-top: 0px
    }

    #title span {
        float: right;
        margin-left: 3.333px;
    }

    .search {
        margin-bottom: 0px !important;
    }

    .asdlkjasd {
        background: #1ab394;
        color: #fff
    }

</style>
 <body class="gray-bg">
 <div class="wrapper wrapper-content {:config('adminClass.main')}">
    <div class="ibox float-e-margins">
        {include file="public/tophead"}
        {include file="public/top" /}
        <div class="ibox-content">
        {include file="public/topsection"}
            <div class="row row-lg">
                <div class="col-sm-12">
                    <div class="fixed-table-toolbar">
                        <a class="btn btn-default btn-outline {present name='paystate'}{eq name='paystate' value='0'}asdlkjasd{/eq}{else /}asdlkjasd{/present}" href="{:url('list',['paystate'=>0])}{present name='status'}/status/{$status}{/present}">全部</a>
                        <a class="btn btn-default btn-outline {present name='paystate'}{eq name='paystate' value='1'}asdlkjasd{/eq}{else /}asdlkjasd{/present}" href="{:url('list',['paystate'=>1])}{present name='status'}/status/{$status}{/present}">已支付</a>
                        <a class="btn btn-default btn-outline {present name='paystate'}{eq name='paystate' value='2'}asdlkjasd{/eq}{else /}asdlkjasd{/present}" href="{:url('list',['paystate'=>2])}{present name='status'}/status/{$status}{/present}">无激励金</a>
                        <a class="btn btn-default btn-outline {present name='paystate'}{eq name='paystate' value='3'}asdlkjasd{/eq}{/present}" href="{:url('list',['paystate'=>3])}{present name='status'}/status/{$status}{/present}">待支付</a>
                    </div>
                    <div class="fixed-table-toolbar">
                        <a class="btn btn-default btn-outline {present name='status'}{eq name='status' value='0'}asdlkjasd{/eq}{/present}" href="{:url('list',['status'=>0])}{present name='paystate'}/paystate/{$paystate}{/present}">坚持中</a>
                        <a class="btn btn-default btn-outline {present name='status'}{eq name='status' value='1'}asdlkjasd{/eq}{else /}asdlkjasd{/present}" href="{:url('list',['status'=>1])}{present name='paystate'}/paystate/{$paystate}{/present}">坚持成功</a>
                        <a class="btn btn-default btn-outline {present name='status'}{eq name='status' value='-1'}asdlkjasd{/eq}{/present}" href="{:url('list',['status'=>-1])}{present name='paystate'}/paystate/{$paystate}{/present}">坚持失败</a>
                    </div>
                    <div class="fixed-table-toolbar">
                        <form  method="get" action="">
                            <div class="pull-left search">
                                <div class="columns columns-right btn-group pull-left" >
                                    <select class="form-control" name="search_typeid">
                                        <option value="user_id" {eq name="search" value="user_id"}selected{/eq}>用户ID</option>
                                        <option value="id" {eq name="search" value="id"}selected{/eq}>ID</option>
                                        <option value="content" {eq name="search" value="content"}selected{/eq}>打卡内容</option>
                                        <option value="number" {eq name="search" value="number"}selected{/eq}>订单号</option>
                                    </select>
                                </div>
                                <div class="columns columns-right btn-group pull-left" >
                                </div>
                                {php}
                                if(input('?param.search_typeid') || input('?param.search_name')){
                                {/php}
                                <div class="pull-right search">
                                    <a class="btn btn-w-m btn-link" href="{:url('list')}">返回管理</a>
                                </div>{php}
                                }
                                {/php}
                                <div class="pull-right search">
                                    <button style="border-radius:0px; border:1px solid #e5e6e7; border-left:0px" class="btn btn-default btn-outline" type="submit">搜索</button>
                                </div>
                                <div class="pull-right search">
                                    <input class="form-control input-outline" id="filter" type="text"
{php}
if(input('?param.search_name')){
            if(input('param.search_name')){
               echo "value='".input('search_name')."'";
            } 
        }
{/php}
                                     name="search_name" placeholder="搜索">
                                </div>
                            </div>
                        </form>
                    </div>
                    <div class="example">
                        <form class="form-horizontal" method="post">
                        <table data-toggle="table">
                            <thead>
                                <tr>
                                    <th data-align="center">ID</th>
                                    <th data-align="center">用户</th>
                                    <th>内容</th>
                                    <th data-align="center">打卡进度</th>
                                    <th data-align="center">打卡地点</th>
                                    <th data-align="center">激励金(元)</th>
                                    <th data-align="center">支付单号</th>
                                    <th data-align="center">支付方式</th>
                                    <th data-align="center">围观人数</th>
                                    <th data-align="center">开始时间</th>
                                    <th data-align="center">下次打卡失效时间</th>
                                    <th data-align="center">创建时间</th>
                                    <th data-align="center">管理</th>
                                </tr>
                            </thead> 
                            <tbody id="form">
                                {volist name="data" id="v"}
                                <tr id="id{$v.id}" class="class">
                                    <td id="id">{$v.id}</td>

                                    <td >
                                        <a onclick="member('{$v.user_id}')" style="color:#40BCF7">{$v.username}<br />(ID:{$v.user_id})</a>
                                    </td>
                                    <td id="title">
                                        <a onclick="watch('{$v.content}')">
                                        <?php echo _substr($v['content']); ?>
                                        </a>
                                    </td>
                                    <td> <a onclick="flags('{$v.id}')">{$v.signday} / {$v.days}</a> </td>
                                    <td> {$v.address} </td>
                                    <td> {$v.price > 0 ? $v.price : '无'} </td>
                                    <td> {$v.number} </td>
                                    <td>
                                        {php}
                                        echo $v['price'] > 0 ? ($v['paymethod'] == 2 ? '支付宝' : '微信') : '';
                                        {/php}
                                    </td>
                                    <td>
                                        {eq name="v.supervise" value="0"}
                                        0
                                        {else}
                                        <a onclick="superviseUser('{$v.id}')" style="color:#40BCF7">{$v.supervise}</a>
                                        {/eq}
                                    </td>
                                    <td> 
                                        {$v.start_date}
                                    </td>
                                    <td> 
                                        <span {php}if(date('Y-m-d')==date('Y-m-d', $v['end_time']))echo 'style="color: #ed5565"';{/php}>
                                            {:date('Y-m-d H:i', $v.end_time)}
                                        </span>
                                    </td>
                                    <td> 
                                        <span {php}if(date('Y-m-d')==date('Y-m-d', $v['create_time']))echo 'style="color: #ed5565"';{/php}>
                                            {:date('Y-m-d H:i', $v.create_time)}
                                        </span>
                                    </td>
                                    <td>
                                        <div class="btn-group">
                                            <div data-toggle="dropdown" class="btn btn-primary btn-xs dropdown-toggle">操作 <span class="caret"></span>
                                            </div>
                                            <ul class="dropdown-menu">
                                                {switch name="v.status"}
                                                {case value="0"}
                                                <li><a onclick="add('{:url('addsign',['id'=>$v.id,'url'=>-1])}')">添加打卡记录</a></li>
                                                <li><a onclick="setStatus({$v.id})">设置失败(瓜分激励金)</a>
                                                </li>
                                                {/case}
                                                {case value="-1"}
                                                <li><a onclick="del({$v.id})">删除</a>
                                                </li>
                                                {/case}
                                                {/switch}
                                            </ul>
                                        </div>
                                    </td>
                                </tr>
                                {/volist}
                            </tbody>                          

                        </table>
                        </form>
                    </div>
                </div>  
            </div>
            <hr>
            <div class="row row-lg">
               <div class="col-sm-6">
                    <a href="?order=1" type="button" class="btn btn-outline btn-default">
                        倒序排序
                    </a>
                    <a href="?order=2" type="button" class="btn btn-outline btn-default">
                        顺序排序
                    </a>
                </div> 
                <div class="col-sm-6 pages">{$page}</div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}
<script type="text/javascript">
function del(id){
    swal_del(id,"{:url('dele')}")
}
function watch(content) {
    layui.use('layer', function(){
      var layer = layui.layer;
      layer.open({
          title :'预览',
          area: ['80vw', '500px'],
          type: 1,
          content: content
        });
    });
}

function member(id)
{
    layui.use('layer', function(){
        var layer = layui.layer;
        layer.open({
            title :'预览',
            area: ['100%', '100%'],
            type: 2,
            content: '{:url("member/index")}?search=id&name='+id
        });
    });
}
function superviseUser(id) {
    layui.use('layer', function(){
        var layer = layui.layer;
        layer.open({
            title :'预览',
            area: ['100%', '100%'],
            type: 2,
            content: '{:url("member/index")}?search=flag_supervise&name='+id
        });
    });
}
function flags(id)
{
    layui.use('layer', function(){
        var layer = layui.layer;
        layer.open({
            title :'预览',
            area: ['100%', '100%'],
            type: 2,
            content: '{:url("content")}?search_type=flag_id&search_name='+id
        });
    });
}
  function setStatus(id){
    let url = "{:url('dele')}?id=" + id
    swal({
        title: "因Flag违规，设置Flag状态为失败(瓜分激励金)",
        text: "操作后将无法恢复，请谨慎操作！",
        type: "warning",
        showCancelButton: true,
        confirmButtonColor: "#DD6B55",
        confirmButtonText: "确定",
        cancelButtonText: "取消",
    },
    function(isConfirm) {
        if (isConfirm) {
            var index = layer.load(1, {
             shade: [0.1,'#fff'] //0.1透明度的白色背景
            });
            ajaxFun("post",url,{id:id},'json',function(ret){
                if(ret){
                    if(ret.ret){
                      setTimeout(()=>{
                        swal_msg(ret.ret,'','success',1)
                      }, 100)
                    }else{
                        layer.msg(ret.err)
                    }
                }else{
                    swal_msg("错误",ret,"error");
                }
                layer.close(index); 
            })
        }
    })
  }
</script>
 